Skip to content

Fix closures on aarch64; add macOS CI - #37

Open
lazarusA wants to merge 1 commit into
JuliaDiff:mainfrom
lazarusA:fix-arm64-macos
Open

lazarusA wants to merge 1 commit into
JuliaDiff:mainfrom
lazarusA:fix-arm64-macos

Conversation

@lazarusA

Copy link
Copy Markdown
Contributor

This issue has been annoying me for a while now. With some 🤖 assistance here is a solution.

🤖

Cause

Polyester builds a @cfunction from the batch body. The do block captured
f (and check), so when f carries data the block is not a singleton. Polyester
then needs a runtime closure cfunction, which Julia only supports on x86/x86_64.

Changes

  • src: pass f and check through batch's argument tuple instead of
    capturing them. The do block captures nothing and stays a singleton on every
    platform. No behaviour change on x86.
  • test: new closures capturing data test set that covers threaded_gradient!
    and both threaded_jacobian! methods with data-capturing closures, with
    Val{false}() and Val{true}(), a length that isn't a multiple of the chunk
    size, and repeated runs with an allocating loss.
  • CI: add macos-latest (aarch64) jobs for Julia 1 and ~1.10.0-0. The new
    tests only catch this bug on Arm with more than one thread, and the existing
    matrix is Linux x86/x64 only. The jobs use the same JULIA_NUM_THREADS=5.

Testing

Locally on Apple silicon (Julia 1.13.4): the new tests error with the message
above on the old code and pass with the fix, with both 8 threads and 1 thread.

closes #36

@codecov

codecov Bot commented Nov 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.22%. Comparing base (694f6e1) to head (51f6787).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #37   +/-   ##
=======================================
  Coverage   96.22%   96.22%           
=======================================
  Files           1        1           
  Lines         106      106           
=======================================
  Hits          102      102           
  Misses          4        4           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lazarusA

Copy link
Copy Markdown
Contributor Author

@ChrisRackauckas let's roll-up an agent review on my agent assisted PR. Should be fine, but another check doesn't hurt, well, additional energy consumption.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

threaded_gradient! / threaded_jacobian! fail on Apple silicon (aarch64) when f is a closure

1 participant